<template>
  <div class="app-container">
    <!-- 修改项目申报对话框 -->
    <vxe-modal :loading="loadings" :close-on-click-modal="false" :key="dialogKey" :title="title"
               v-model="modifyProject" width="95%"
               showFooter show-zoom resize
               @close="cancel">
      <!-- @close="cancel" 判断有没有点击右上角的X关闭按钮-->
      <el-form ref="formDialog" :model="form" :rules="rules" label-width="96px">

        <el-tabs tab-position="right" type="border-card" v-model="activeName">
          <el-tab-pane name="xmjbxx" label="项目基本信息">
            <div v-if="activeName === 'xmjbxx'" style="height: 75vh; overflow-y: auto;">

              <el-card class="box-card">
                <el-row :gutter="24">
                  <el-col :span="12">
                    <el-form-item label="课题归属:" prop="ktGs">
                      <el-select v-model="form.ktGs" placeholder="请选择课题归属">
                        <el-option
                          v-for="dict in dict.type.kylx_ktgs"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="年度:" prop="year">
                      <el-select v-model="form.year" placeholder="请选择年度">
                        <el-option
                          v-for="dict in dict.type.year"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>

              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff">课题基本信息</span>
                </div>
                <el-row :gutter="24">
                  <el-col :span="6">
                    <el-form-item label="课题名称" prop="ktName">
                      <el-input disabled v-model="form.ktName" placeholder="请输入课题名称"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="课题编号" prop="ktBh">
                      <el-input v-model="form.ktBh" placeholder="请输入课题编号" :disabled="true"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="申报单位" prop="zrBm">
                      <treeselect v-model="form.zrBm" :options="deptOptions" placeholder="请选择责任部门"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="课题分类" prop="ktFl">
                      <el-select multiple filterable v-model="form.ktFl" placeholder="请选择课题分类">
                        <el-option
                          v-for="dict in dict.type.kylx_ktfl"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="起止时间:" prop="qTime">
                      <el-date-picker
                        v-model="form.qTime"
                        type="monthrange"
                        range-separator="至"
                        start-placeholder="开始月份"
                        end-placeholder="结束月份">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <!--                <el-col :span="8">-->
                  <!--              <el-form-item label="至" prop="zTime">-->
                  <!--                <el-date-picker clearable-->
                  <!--                                v-model="form.zTime"-->
                  <!--                                type="date"-->
                  <!--                                value-format="yyyy-MM-dd"-->
                  <!--                                placeholder="">-->
                  <!--                </el-date-picker>-->
                  <!--              </el-form-item>-->
                  <!--                </el-col>-->
                  <el-col :span="8">
                    <el-form-item label="依托工程" prop="ytGc">
                      <el-input v-model="form.ytGc" placeholder="请输入依托工程"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="录入人员" prop="lrRy">
                      <el-input v-model="form.lrRy" placeholder="请输入录入人员"/>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="申报日期" prop="sbRq">
                      <el-date-picker clearable
                                      v-model="form.sbRq"
                                      type="date"
                                      value-format="yyyy-MM-dd"
                                      placeholder="请选择申报日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="项目分类(财务系统)" prop="xmFlCwxt" label-width="150px">
                      <el-select filterable v-model="form.xmFlCwxt" placeholder="请选择项目分类(财务系统)">
                        <el-option
                          v-for="dict in dict.type.kylx_xmfl_cwxt"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="所属领域" prop="ssLy">
                      <el-select filterable v-model="form.ssLy" placeholder="请选择所属领域">
                        <el-option
                          v-for="dict in dict.type.kylx_ssly"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="高企服务" prop="gqFw">
                      <el-select filterable v-model="form.gqFw" placeholder="请选择高企服务">
                        <el-option
                          v-for="dict in dict.type.kylx_gqfw"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="项目研发级别" prop="xmYfJb" label-width="150px">
                      <el-select filterable v-model="form.xmYfJb" placeholder="请选择项目研发级别">
                        <el-option
                          v-for="dict in dict.type.kylx_yfxmjb"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="合作方式" prop="hzFs">
                      <el-select filterable v-model="form.hzFs" placeholder="请选择合作方式">
                        <el-option
                          v-for="dict in dict.type.kylx_hzfs"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="国家" prop="gj">
                      <el-select filterable v-model="form.gj" placeholder="请选择国家">
                        <el-option
                          v-for="dict in dict.type.kylx_country"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="所属领域(财务系统)" prop="ssLyCwxt">
                      <el-select v-model="form.ssLyCwxt" placeholder="请选择所属领域(财务系统)">
                        <el-option
                          v-for="dict in dict.type.kylx_ssly_cwxt"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="币种" prop="bz">
                      <el-select filterable v-model="form.bz" placeholder="请选择币种">
                        <el-option
                          v-for="dict in dict.type.kylx_bz"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>

              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff">项目负责人情况</span>
                </div>
                <el-row :gutter="24">
                  <el-col :span="6">
                    <el-form-item label="姓名" prop="fzName">
                      <el-input v-model="form.fzName" placeholder="请输入姓名" @focus="selectUser"
                                :suffix-icon="'el-icon-search'"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="性别" prop="fzXb">
                      <el-select filterable v-model="form.fzXb" placeholder="请选择性别">
                        <el-option
                          v-for="dict in dict.type.sys_user_sex"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="年龄" prop="fzNl">
                      <el-input v-model="form.fzNl" placeholder="请输入年龄"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="专业" prop="fzZy">
                      <el-input v-model="form.fzZy" placeholder="请输入专业"/>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="联系电话" prop="fzPhone">
                      <el-input v-model="form.fzPhone" placeholder="请输入联系电话"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="职称" prop="fzZc">
                      <el-select filterable v-model="form.fzZc" placeholder="请选择职称">
                        <el-option
                          v-for="dict in dict.type.rcpt_zc"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="邮政编码" prop="fzYzbm">
                      <el-input v-model="form.fzYzbm" placeholder="请输入邮政编码"/>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-form-item label="通讯地址" prop="txdz">
                  <el-input v-model="form.txdz" placeholder="请输入通讯地址"/>
                </el-form-item>
              </el-card>

              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff">项目组成员人数</span>
                </div>
                <el-row :gutter="24">
                  <el-col :span="4">
                    <el-form-item label="总人数" prop="zrs">
                      <el-input type="number" v-model.number="form.zrs" placeholder="请输入总人数"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="4">
                    <el-form-item label="高级人数" prop="gjrs">
                      <el-input type="number" v-model.number="form.gjrs" placeholder="请输入高级人数"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="4">
                    <el-form-item label="中级人数" prop="zjrs">
                      <el-input type="number" v-model.number="form.zjrs" placeholder="请输入中级人数"/>
                    </el-form-item>
                  </el-col>

                  <el-col :span="4">
                    <el-form-item label="研究生人数" prop="yjsrs">
                      <el-input type="number" v-model.number="form.yjsrs" placeholder="请输入研究生人数"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="4">
                    <el-form-item label="初级人数" prop="cjrs">
                      <el-input type="number" v-model.number="form.cjrs" placeholder="请输入初级人数"/>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>

              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">课题经费</span>
                </div>
                <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="项目总额(万)" prop="xmze" label-width="110px">
                      <el-input type="number" disabled v-model.number="form.xmze" placeholder="请输入项目总额(万)"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="申请资助(万)" prop="sqzz" label-width="110px">
                      <el-input type="number" v-model.number="form.sqzz" placeholder="请输入申请资助(万)"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="自筹金额" prop="zcje">
                      <el-input type="number" v-model.number="form.zcje" placeholder="请输入自筹金额"/>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="dwyj" label="单位意见">
            <div v-if="activeName === 'dwyj'" style="height: 75vh; overflow-y: auto;">
              <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">申请单位意见</span>
                </div>
                <el-form-item label="" prop="sqDwYj">
                  <el-input v-model="form.sqDwYj" type="textarea" placeholder="请输入申请单位意见" show-word-limit
                            :autosize="{minRows: 10, maxRows: 10}" :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-card>
              <br>
              <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">初审意见</span>
                </div>
                <el-form-item label="" prop="csYj">
                  <el-input v-model="form.csYj" type="textarea" placeholder="请输入初审意见" show-word-limit
                            :autosize="{minRows: 10, maxRows: 10}" :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="xmgs" label="1、项目概述">
            <div  style="height:75vh; overflow-y: auto;">
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">目的和意义</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.mdAndYy" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">国内外概况及发展趋势</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.gnwgkAndFzqs" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="xmzykfnr" label="2、项目主要研究开发内容、技术关键、创新性">
            <!--            <div v-if="activeName === 'xmzykfnr'" style="height: 75vh; overflow-y: auto;">-->
            <div style="height: 75vh; overflow-y: auto;">
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;"><span
                  style="font-size: 20px; color: #1890ff;">主要研究开发内容</span>
                  <span style="font-size: 14px; color: red;">（限制在1200字以内）</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.zyjjKfnr" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">关键技术</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.gjJs" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">创新性</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.cxx" :min-height="192"/>
                <!--                </el-form-item>-->
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="jsxnzb" label="3、技术性能指标和预期成果形式">
            <div style="height: 75vh; overflow-y: auto;">
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">预期达到的技术经济指标</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.yqddJsjjzb" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">预期成果和提供的形式</span>
                </div>
                <!--                <el-form-item label="">-->
                <editor v-model="form.yqcgAndTgdxs" :min-height="135"/>
                <!--                </el-form-item>-->
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="xmjhjd" label="4、项目计划进度和目标">
            <div style="height:75vh; overflow-y: auto;">
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">项目计划进度和目标</span>
                </div>
                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddLxglXmsbJhjd">添加
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbJhjd">删除
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="success" icon="el-icon-folder-checked" size="mini" @click="submitForm">保存
                    </el-button>
                  </el-col>
                </el-row>
                <el-table height="450" style="max-height: 900px; overflow-y: auto;" border
                          :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbJhjdList" :row-class-name="rowLxglXmsbJhjdIndex"
                          @selection-change="handleLxglXmsbJhjdSelectionChange" ref="lxglXmsbJhjd">
                  <el-table-column type="selection" width="50" align="center"/>
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="开始日期" prop="ksRq" align="center">
                    <template slot-scope="scope">
                      <el-date-picker clearable v-model="scope.row.ksRq" type="month" value-format="yyyy-MM"
                                      placeholder="请选择开始日期" style="width: 95%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="结束日期" prop="jsRq" align="center">
                    <template slot-scope="scope">
                      <el-date-picker clearable v-model="scope.row.jsRq" type="month" value-format="yyyy-MM"
                                      placeholder="请选择结束日期" style="width: 95%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="研发内容" prop="yfNr" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.yfNr" :rows="2" type="textarea" placeholder="请输入研发内容"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="阶段目标" prop="jdMb" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.jdMb" :rows="2" type="textarea" placeholder="请输入阶段目标"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" width="120">
                    <template slot-scope="scope">
                      <el-button type="text" icon="el-icon-arrow-up" size="mini" @click="moveJhjdUp(scope.$index)" :disabled="scope.$index === 0">上移</el-button>
                      <el-button type="text" icon="el-icon-arrow-down" size="mini" @click="moveJhjdDown(scope.$index)" :disabled="scope.$index === lxglXmsbJhjdList.length - 1">下移</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="ktcddw" label="5、课题承担单位的条件">
            <div v-if="activeName === 'ktcddw'" style="height: 75vh; overflow-y: auto;">
              <!-- 课题负责人(课题负责人的情况介绍) -->
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">课题负责人(课题负责人的情况介绍)</span>
                </div>
                <el-form-item label="" prop="ktfzrQkjs">
                  <el-input :rows="5" v-model="form.ktfzrQkjs" type="textarea" placeholder="请输入内容"/>
                </el-form-item>
              </el-card>
              <!-- 研究课题组成人员情况信息 -->
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">研究课题组成人员情况信息</span>
                </div>
                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddLxglXmsbZcry">添加</el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbZcry">删除</el-button>
                  </el-col>
                </el-row>
                <el-table :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          style="min-height: 30vh" :data="lxglXmsbZcryList" :row-class-name="rowLxglXmsbZcryIndex"
                          @selection-change="handleLxglXmsbZcrySelectionChange" ref="lxglXmsbZcry">
                  <el-table-column type="selection" width="50" align="center" />
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="姓名" align="center" show-overflow-tooltip prop="name" width="100">
                  </el-table-column>
                  <el-table-column label="年龄" align="center" show-overflow-tooltip prop="age" width="60">
                  </el-table-column>
                  <el-table-column label="职务" align="center" show-overflow-tooltip prop="zhiWu">
                  </el-table-column>
                  <el-table-column label="职称" align="center" prop="zhiChen">
                    <template slot-scope="scope">
                      <dict-tag :options="dict.type.rcpt_zc" :value="scope.row.zhiChen"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="专业" align="center" show-overflow-tooltip prop="zy">
                  </el-table-column>
                  <el-table-column align="center" label="本课题中分工" prop="bKtFg">
                    <template slot-scope="scope">
                      <el-select v-model="scope.row.bKtFg" placeholder="请选择本课题中分工">
                        <el-option
                          v-for="dict in dict.type.kylx_zcry_ktfg"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="投入课题工作总月数" prop="trZys">
                    <template slot-scope="scope">
                      <el-input type="number" v-model.number="scope.row.trZys" placeholder="请输入投入课题工作总月数" />
                    </template>
                  </el-table-column>
                  <el-table-column align="center" show-overflow-tooltip label="工作单位" prop="gzDw">
                  </el-table-column>
                  <el-table-column label="操作" width="120">
                    <template slot-scope="scope">
                      <el-button type="text" icon="el-icon-arrow-up" size="mini" @click="moveUp(scope.$index)" :disabled="scope.$index === 0">上移</el-button>
                      <el-button type="text" icon="el-icon-arrow-down" size="mini" @click="moveDown(scope.$index)" :disabled="scope.$index === lxglXmsbZcryList.length - 1">下移</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="xmdjfys" label="6、项目的经费预算">
            <div v-if="activeName === 'xmdjfys'" style="height: 75vh; overflow-y: auto;">
              <el-card class="box-card">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">研发费用预算表</span>
                </div>
                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddLxglXmsbYffy">添加
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbYffy">删除
                    </el-button>
                  </el-col>
                </el-row>
                <el-table @row-click="clickJfysRow" highlight-current-row
                          show-summary sum-text="汇总" :summary-method="getSummaries"
                          border height="25vh"
                          :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbYffyList" :row-class-name="rowLxglXmsbYffyIndex"
                          @selection-change="handleLxglXmsbYffySelectionChange" ref="lxglXmsbYffy">
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="年份" prop="yffyYear" align="center" width="200">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.yffyYear" placeholder="请输入年份"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="申请资助(万元)" prop="sqzz" align="center" width="250">
                    <template slot-scope="scope">
                      <el-input-number v-model="scope.row.sqzz" :min="0" label="请输入申请资助(万元)"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="自筹金额(万元)" prop="zcje" align="center" width="250">
                    <template slot-scope="scope">
                      <el-input-number v-model="scope.row.zcje" :min="0" label="请输入自筹金额(万元)"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column label="备注" prop="remark" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.remark" placeholder="请输入备注"/>
                    </template>
                  </el-table-column>
                </el-table>

                <br>
                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="success" icon="el-icon-folder-checked" size="mini" @click="submitForm">保存
                    </el-button>
                  </el-col>
                </el-row>
                <el-table height="28.1vh" :key="updateKey" show-summary sum-text="汇总"
                          :summary-method="getSummariesFfyys"
                          :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbYffyysList" :row-class-name="rowLxglXmsbYffyysIndex"
                          @selection-change="handleLxglXmsbYffyysSelectionChange" ref="lxglXmsbYffyys">
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="项目" prop="xm" show-overflow-tooltip header-align="center"
                                   width="400" style="font-weight: 600;"/>
                  <el-table-column label="项目总预算(万元)" prop="xmZys" header-align="center">
                    <template slot-scope="scope">
                      <span v-if="1 === 1">
                        {{ scope.row.xmZys }}
                      </span>

                    </template>
                  </el-table-column>
                  <el-table-column label="第一年度预算" prop="oneYs" header-align="center">
                    <template slot-scope="scope">
                      <el-input type="number"
                                v-if="scope.$index !== 0 && scope.$index !== 4 && scope.$index !== 9 && scope.$index !== 14 && scope.$index !== 19 && scope.$index !== 23 && scope.$index !== 29"
                                v-model="scope.row.oneYs" placeholder=""
                                @focus="jianCloumVal(scope.$index, scope.row.oneYs)"
                                @blur="calcCloumVal(scope.$index, scope.row.oneYs, scope.row)"/>
                      <span v-else>
                        {{ scope.row.oneYs }}
                      </span>
                    </template>
                  </el-table-column>
                  <el-table-column label="第二年度预算" prop="towYs" header-align="center">
                    <template slot-scope="scope">
                      <el-input type="number"
                                v-if="scope.$index !== 0 && scope.$index !== 4 && scope.$index !== 9 && scope.$index !== 14 && scope.$index !== 19 && scope.$index !== 23 && scope.$index !== 29"
                                v-model="scope.row.towYs" placeholder=""
                                @focus="jianCloumVal(scope.$index, scope.row.towYs)"
                                @blur="calcCloumVal(scope.$index, scope.row.towYs, scope.row)"/>
                      <span v-else>
                        {{ scope.row.towYs }}
                      </span>
                    </template>
                  </el-table-column>
                  <el-table-column label="第三年度预算" prop="threeYs" header-align="center">
                    <template slot-scope="scope">
                      <el-input type="number"
                                v-if="scope.$index !== 0 && scope.$index !== 4 && scope.$index !== 9 && scope.$index !== 14 && scope.$index !== 19 && scope.$index !== 23 && scope.$index !== 29"
                                v-model="scope.row.threeYs" placeholder=""
                                @focus="jianCloumVal(scope.$index, scope.row.threeYs)"
                                @blur="calcCloumVal(scope.$index, scope.row.threeYs)"/>
                      <span v-else>
                        {{ scope.row.threeYs }}
                      </span>
                    </template>
                  </el-table-column>
                  <el-table-column label="第四年度预算" prop="fourYs" header-align="center">
                    <template slot-scope="scope">
                      <el-input type="number"
                                v-if="scope.$index !== 0 && scope.$index !== 4 && scope.$index !== 9 && scope.$index !== 14 && scope.$index !== 19 && scope.$index !== 23 && scope.$index !== 29"
                                v-model="scope.row.fourYs" placeholder=""
                                @focus="jianCloumVal(scope.$index, scope.row.fourYs)"
                                @blur="calcCloumVal(scope.$index, scope.row.fourYs)"/>
                      <span v-else>
                        {{ scope.row.fourYs }}
                      </span>
                    </template>
                  </el-table-column>
                  <el-table-column label="第五年度预算" prop="fiveYs" header-align="center">
                    <template slot-scope="scope">
                      <el-input type="number"
                                v-if="scope.$index !== 0 && scope.$index !== 4 && scope.$index !== 9 && scope.$index !== 14 && scope.$index !== 19 && scope.$index !== 23 && scope.$index !== 29"
                                v-model="scope.row.fiveYs" placeholder=""
                                @focus="jianCloumVal(scope.$index, scope.row.fiveYs)"
                                @blur="calcCloumVal(scope.$index, scope.row.fiveYs)"/>
                      <span v-else>
                        {{ scope.row.fiveYs }}
                      </span>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </div>
          </el-tab-pane>

          <el-tab-pane name="fb" label="7、附表">
            <div v-if="activeName === 'fb'" style="height: 75vh; overflow-y: auto;">
              <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">直接用于研发的主要材料</span>
                </div>

                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddsLxglXmsbYfcl">添加
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbYfcl">删除
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="success" icon="el-icon-folder-checked" size="mini" @click="submitForm">保存
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-tooltip placement="top" effect="light">
                      <div slot="content">在Excel中选中需要粘贴的表格信息<br/>点击此按钮<br/>ctry + v<br/>即可粘贴</div>
                      <el-button type="warning" icon="el-icon-document-copy" size="mini"
                                 @click="handleYfclPasteFromExcel">粘贴Excel
                      </el-button>
                    </el-tooltip>
                  </el-col>
                </el-row>
                <el-table height="25vh" :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbYfclList" :row-class-name="rowLxglXmsbYfclIndex"
                          @selection-change="handleLxglXmsbYfclSelectionChange" ref="lxglXmsbYfcl">
                  <el-table-column type="selection" width="50" align="center"/>
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="名称" prop="clName">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.clName" placeholder="请输入名称"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="单位" prop="clUnit">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.clUnit" placeholder="请输入单位"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="预计用量" prop="clDosage">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.clDosage" placeholder="请输入预计用量"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="备注" prop="clRemarks">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.clRemarks" placeholder="请输入备注"/>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>

              <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">设备（专门用于研发主要仪器、设备清单）</span>
                </div>

                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddsLxglXmsbYfsb">添加
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbYfsb">删除
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="success" icon="el-icon-folder-checked" size="mini" @click="submitForm">保存
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-tooltip placement="top" effect="light">
                      <div slot="content">在Excel中选中需要粘贴的表格信息<br/>点击此按钮<br/>ctry + v<br/>即可粘贴</div>
                      <el-button type="warning" icon="el-icon-document-copy" size="mini"
                                 @click="handleYfsbPasteFromExcel">粘贴Excel
                      </el-button>
                    </el-tooltip>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="warning" icon="el-icon-download" size="mini" @click="handleDownloadYfsbExcel">
                      粘贴模板下载
                    </el-button>
                  </el-col>
                </el-row>
                <el-table height="25vh" :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbYfsbList" :row-class-name="rowLxglXmsbYfsbIndex"
                          @selection-change="handleLxglXmsbYfsbSelectionChange" ref="lxglXmsbYfsb">
                  <el-table-column type="selection" width="50" align="center"/>
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="名称" prop="sbName">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.sbName" placeholder="请输入名称"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="型号" prop="sbModel">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.sbModel" placeholder="请输入型号"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="价格(万元)" prop="sbPrice">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.sbPrice" placeholder="请输入价格(万元)"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="备注" prop="sbRemarks">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.sbRemarks" placeholder="备注"/>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>

              <el-card class="box-card" shadow="never">
                <div slot="header" class="clearfix" style="text-align: center;">
                  <span style="font-size: 20px; color: #1890ff;">中间试验费</span>
                </div>
                <el-row :gutter="10" class="mb8">
                  <el-col :span="1.5">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddsLxglXmsbZjsyf">添加
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbZjsyf">删除
                    </el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="warning" icon="el-icon-document-copy" size="mini"
                               @click="handleZjsyfPasteFromExcel">粘贴Excel
                    </el-button>
                  </el-col>
                </el-row>
                <el-table height="25vh" :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                          :data="lxglXmsbZjsyfList" :row-class-name="rowLxglXmsbZjsyfIndex"
                          @selection-change="handleLxglXmsbZjsyfSelectionChange" ref="lxglXmsbZjsyf">
                  <el-table-column type="selection" width="50" align="center"/>
                  <el-table-column label="序号" align="center" prop="index" width="50"/>
                  <el-table-column label="试验(检测)项目" prop="testingItems">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.testingItems" placeholder="请输入试验(检测)项目"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="价格(万元)" prop="price">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.price" placeholder="请输入价格(万元)"/>
                    </template>
                  </el-table-column>
                  <el-table-column label="备注" prop="remarks">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.remarks" placeholder="请输入备注"/>
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>

            </div>
          </el-tab-pane>

          <el-tab-pane name="yjkfandppt" label="8、附件: 研究开发计划书及ppt">
            <div v-if="activeName === 'yjkfandppt'" style="height: 75vh; overflow-y: auto;">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <!-- 上传按钮 -->
                  <el-button size="mini" icon="el-icon-upload" type="primary" @click="yjKfAndPptFjShangChuan">上传</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbFj">删除
                  </el-button>
                </el-col>
              </el-row>
              <el-table border :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                        :data="yjKfAndPptFiles" :row-class-name="rowLxglXmsbFjIndex"
                        @selection-change="handleLxglXmsbFjSelectionChange" ref="lxglXmsbFj">
                <el-table-column type="selection" align="center"/>
                <!--          <el-table-column label="序号" align="center" prop="index"/>-->
                <el-table-column label="文件类型" prop="fileType" align="center">
                </el-table-column>
                <el-table-column label="文件名称" prop="fileName" align="center" :formatter="getFileNames"
                                 show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="文件大小" prop="fileSize" align="center"/>
                <el-table-column label="操作" align="center">
                  <template slot-scope="scope">

                    <el-popconfirm
                      title="确定要删除此附件吗？"
                      @confirm="handleXmsbFileDelete(scope.row)"
                    >
                      <el-button
                        slot="reference"
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                      >删除
                      </el-button>
                    </el-popconfirm>

                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleDownload(scope.row)"
                    >下载
                    </el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

          <el-tab-pane name="kxxyjbg" label="8.1、可行性研究报告">
            <div v-if="activeName === 'kxxyjbg'" style="height: 75vh; overflow-y: auto;">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <!-- 上传按钮 -->
                  <el-button size="mini" icon="el-icon-upload" type="primary" @click="kyFjShangChuan">上传</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbFj">删除
                  </el-button>
                </el-col>
              </el-row>
              <el-table border :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                        :data="researchReportFiles" :row-class-name="rowLxglXmsbFjIndex"
                        @selection-change="handleLxglXmsbFjSelectionChange" ref="lxglXmsbFj">
                <el-table-column type="selection" align="center"/>
                <!--          <el-table-column label="序号" align="center" prop="index"/>-->
                <el-table-column label="文件类型" prop="fileType" align="center">
                </el-table-column>
                <el-table-column label="文件名称" prop="fileName" align="center" :formatter="getFileNames"
                                 show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="文件大小" prop="fileSize" align="center"/>
                <el-table-column label="操作" align="center">
                  <template slot-scope="scope">

                    <el-popconfirm
                      title="确定要删除此附件吗？"
                      @confirm="handleXmsbFileDelete(scope.row)"
                    >
                      <el-button
                        slot="reference"
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                      >删除
                      </el-button>
                    </el-popconfirm>

                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleDownload(scope.row)"
                    >下载
                    </el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

          <el-tab-pane name="cxbg" label="8.2、查新报告">
            <div v-if="activeName === 'cxbg'" style="height: 75vh; overflow-y: auto;">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <!-- 上传按钮 -->
                  <el-button size="mini" icon="el-icon-upload" type="primary" @click="cxbgFjShangChuan">上传</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbFj">删除
                  </el-button>
                </el-col>
              </el-row>
              <el-table border :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                        :data="cxbgFiles" :row-class-name="rowLxglXmsbFjIndex"
                        @selection-change="handleLxglXmsbFjSelectionChange" ref="lxglXmsbFj">
                <el-table-column type="selection" align="center"/>
                <!--          <el-table-column label="序号" align="center" prop="index"/>-->
                <el-table-column label="文件类型" prop="fileType" align="center">
                </el-table-column>
                <el-table-column label="文件名称" prop="fileName" align="center" :formatter="getFileNames"
                                 show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="文件大小" prop="fileSize" align="center"/>
                <el-table-column label="操作" width="120" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">

                    <el-popconfirm
                      title="确定要删除此附件吗？"
                      @confirm="handleXmsbFileDelete(scope.row)"

                    >
                      <el-button
                        slot="reference"
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                      >删除
                      </el-button>
                    </el-popconfirm>

                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleDownload(scope.row)"
                    >下载
                    </el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

          <el-tab-pane name="zscqfx" label="8.3、知识产权分析报告">
            <div v-if="activeName === 'zscqfx'" style="height: 75vh; overflow-y: auto;">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <!-- 上传按钮 -->
                  <el-button size="mini" icon="el-icon-upload" type="primary" @click="zscqfxFjShangChuan">上传
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbFj">删除
                  </el-button>
                </el-col>
              </el-row>
              <el-table border :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                        :data="zscqfxbgFiles" :row-class-name="rowLxglXmsbFjIndex"
                        @selection-change="handleLxglXmsbFjSelectionChange" ref="lxglXmsbFj">
                <el-table-column type="selection" align="center"/>
                <!--          <el-table-column label="序号" align="center" prop="index"/>-->
                <el-table-column label="文件类型" prop="fileType" align="center">
                </el-table-column>
                <el-table-column label="文件名称" prop="fileName" align="center" :formatter="getFileNames"
                                 show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="文件大小" prop="fileSize" align="center"/>
                <el-table-column label="操作" width="120" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">

                    <el-popconfirm
                      title="确定要删除此附件吗？"
                      @confirm="handleXmsbFileDelete(scope.row)"

                    >
                      <el-button
                        slot="reference"
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                      >删除
                      </el-button>
                    </el-popconfirm>

                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleDownload(scope.row)"
                    >下载
                    </el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

          <el-tab-pane name="xmsp" label="8.4、项目审批意见">
            <div v-if="activeName === 'xmsp'" style="height: 75vh; overflow-y: auto;">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <!-- 上传按钮 -->
                  <el-button size="mini" icon="el-icon-upload" type="primary" @click="xmspyjFjShangChuan">上传
                  </el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteLxglXmsbFj">删除
                  </el-button>
                </el-col>
              </el-row>
              <el-table border :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
                        :data="xmspyjFiles" :row-class-name="rowLxglXmsbFjIndex"
                        @selection-change="handleLxglXmsbFjSelectionChange" ref="lxglXmsbFj">
                <el-table-column type="selection" align="center"/>
                <!--          <el-table-column label="序号" align="center" prop="index"/>-->
                <el-table-column label="文件类型" prop="fileType" align="center">
                </el-table-column>
                <el-table-column label="文件名称" prop="fileName" align="center" :formatter="getFileNames"
                                 show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="文件大小" prop="fileSize" align="center"/>
                <el-table-column label="操作" width="120" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">

                    <el-popconfirm
                      title="确定要删除此附件吗？"
                      @confirm="handleXmsbFileDelete(scope.row)"

                    >
                      <el-button
                        slot="reference"
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                      >删除
                      </el-button>
                    </el-popconfirm>

                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleDownload(scope.row)"
                    >下载
                    </el-button>

                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>

        </el-tabs>

      </el-form>
      <div slot="footer" class="dialog-footer" style="display: flex; justify-content: center;">
        <el-button icon="el-icon-check" size="mini" type="primary" @click="submitForm">保 存</el-button>
        <el-button icon="el-icon-close" size="mini" type="info" @click="cancel">关 闭</el-button>
      </div>
    </vxe-modal>

    <!-- 附件上传弹窗 -->
    <el-dialog title="附件上传" v-if="fjShangChuan === true" :visible.sync="fjShangChuan" width="25%" append-to-body @close="fjClose">
      <el-upload
        align="center"
        class="upload-demo"
        multiple
        :action="uploadFileUrl"
        :before-upload="handleBeforeUpload"
        :file-list="fileList"
        :limit="20"
        :on-error="handleUploadError"
        :on-exceed="handleExceed"
        :on-success="handleUploadSuccess"
        :headers="headers"
        ref="fileUpload"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
          请上传
          <template> 大小不超过 <b style="color: #f56c6c">{{ 50 }}MB</b></template>
          <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
          的文件
        </div>
      </el-upload>

      <div slot="footer" class="dialog-footer" style="display: flex; justify-content: center;">
        <el-button v-if="allFilesUploaded === false" size="mini" type="primary" @click="fjShangChuan = false">关 闭</el-button>
        <el-button v-if="allFilesUploaded === true" size="mini" type="primary" @click="fjShangChuan = false">上传完成, 关闭</el-button>
      </div>

    </el-dialog>

    <!-- 查询项目申报(主表 + 子表) 弹窗 -->
    <Xmxq ref="xmxq"/>

    <!-- 查看项目预算 弹窗 -->
    <XmZe ref="xmze"/>

    <!-- 填报说明弹窗 -->
    <vxe-modal v-if="tbsmVisible === true" v-model="tbsmVisible" title="规范查看" width="50%" center esc-closable>
      <filling-instructions/>
    </vxe-modal>

    <!-- 单选科技人员 -->
    <KjryDx ref="kjrydx"/>

    <!-- 多选科技人员 -->
    <KjryDuoX ref="ktryDuoXuan"/>
  </div>
</template>

<script>
import {
  addXmsb,
  delXmsb,
  exportXmsbWord,
  getXmsb, getXmsbList,
  insertLxglXmsbFjByxmsbId,
  removeFileBySunId,
  selectCountLxbh,
  selectLlglXmsbByjhjdByXmsbId,
  selectLlglXmsbByYfclByXmsbId,
  selectLlglXmsbByyffyByXmsbId,
  selectLlglXmsbByyffysByXmsbId,
  selectLlglXmsbYfsbByXmsbId,
  selectLlglXmsbZcryByXmsbId,
  selectLlglXmsbZjsyfByXmsbId,
  selectLxglXmsbFjList,
  selectMAXId,
  updateKtgs,
  updateXmsb
} from "@/api/xmgl/lxgl/xmsb/xmsb";
import {startTask, revokeProcess} from "@/api/activiti/task";
import {getToken} from "@/utils/auth";
import {getInfo} from "@/api/login";
import {quillEditor} from 'vue-quill-editor';
import {deptTreeSelect} from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import FillingInstructions from "@/views/xmgl/lxgl/xmsb/components/fillingInstructions";
import Xmxq from "@/views/xmgl/lxgl/xmsb/components/xmxq";
import XmsbSc from "@/views/xmgl/lxgl/xmsb/components/xmsbSc";
import KjryDx from "@/views/components/kjryXz/kjryDx";
import vueQr from "vue-qr";
import Jindu from "@/views/components/liuChengState/jindu";
import XmZe from "@/views/xmgl/lxgl/xmsb/components/xmZe";
import KjryDuoX from "@/views/components/kjryXz/kjryDuoX";

export default {
  name: "LxSbBj",
  components: {KjryDuoX, XmZe, Jindu, KjryDx, XmsbSc, Xmxq, FillingInstructions, Treeselect, vueQr},
  comments: {quillEditor},
  dicts: ['kylx_fjlx', 'process_business_status', 'rcpt_zc', 'process_business_status', 'kylx_zcry_ktfg', 'year', 'kylx_ssly_cwxt', 'kylx_gqfw', 'kylx_country', 'sys_user_sex', 'kylx_xmfl_cwxt', 'kylx_ssly', 'kylx_hzfs', 'rcpt_zc', 'kylx_yfxmjb', 'kylx_ktgs', 'kylx_ktfl', 'kylx_bz'],
  computed: {
    yjKfAndPptFiles() {
      return this.lxglXmsbFjList.filter(file => file.fileType === '研究开发计划书及ppt');
    },
    researchReportFiles() {
      return this.lxglXmsbFjList.filter(file => file.fileType === '可行性研究报告');
    },
    cxbgFiles() {
      return this.lxglXmsbFjList.filter(file => file.fileType === '查新报告');
    },
    zscqfxbgFiles() {
      return this.lxglXmsbFjList.filter(file => file.fileType === '知识产权分析报告');
    },
    xmspyjFiles() {
      return this.lxglXmsbFjList.filter(file => file.fileType === '项目审批意见');
    }
  },
  created() {
    this.getDeptTree();
  },
  provide() {
    return {
      updateKjRyLabel: (val) => {
        this.form.fzName = val.name; //赋值给项目申报页面的负责人姓名
        this.form.fzXb = val.sex; //赋值给项目申报页面的负责人性别
        this.form.fzNl = val.age; //赋值给项目申报页面的负责人年龄
        this.form.fzZy = val.sxZy; //赋值给项目申报页面的负责人专业
        this.form.fzPhone = val.phone; //赋值给项目申报页面的负责人联系电话
        this.form.fzZc = val.zc; //赋值给项目申报页面的负责人职称
      },
      //赋值给 研究课题组成人员情况信息 列表
      updateKtZcRyLabel: (val) => {
        val.forEach(item => {
          // 检查是否已存在相同的 kjryId
          const exists = this.lxglXmsbZcryList.some(existingItem => existingItem.kjryId === item.kjryId);
          if (!exists) {
            this.lxglXmsbZcryList.push(item);
          }
        })
      },
    };
  },
  updated() {
    if (this.$refs.lxglXmsbYffy) {
      this.$nextTick(() => {
        this.$refs.lxglXmsbYffy.doLayout();
      });
    }
  },
  data() {
    return {
      loadings: false,
      activeName: 'xmjbxx', //默认打开的标签
      allFilesUploaded: false, // 添加这个来追踪所有文件是否上传完成
      // 中间试验费子表选中数据
      checkedLxglXmsbZjsyf: [],
      // 研发设备子表选中数据
      checkedLxglXmsbYfsb: [],
      // 研发材料子表选中数据
      checkedLxglXmsbYfcl: [],
      // 课题组成人员子表选中数据
      checkedLxglXmsbZcry: [],
      updateKey: false,
      selectedRow: null, // 保存当前选中的行
      // 子表选中数据
      checkedLxglXmsbYffyys: [],
      // 研发费用预算下表格数据
      lxglXmsbYffyysList: [],
      // 研发费用预算上表格数据
      lxglXmsbYffyList: [],
      // 直接用于研发的主要材料表格数据
      lxglXmsbYfclList: [],
      // 设备（专门用于研发主要仪器、设备清单）表格数据
      lxglXmsbYfsbList: [],
      // 中间试验费表格数据
      lxglXmsbZjsyfList: [],
      // 研究课题组成人员情况表格数据
      lxglXmsbZcryList: [],
      tbsmVisible: false, //填报说明弹窗
      lxglXmsbJhjdList: [], // 项目计划进度和目标表格数据
      dialogKey: 0, // 初始化 key 值
      deptOptions: undefined, // 部门树选项
      xmsbFileType: '', //附件文件类型(可研性研究报告........)
      modifyProject: false, //修改项目弹窗
      fjShangChuan: false, //附件上传弹窗
      xmsbIdEdit: "", //要修改的 项目id
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
      fileList: [],
      headers: {Authorization: "Bearer " + getToken()},
      number: 0,
      uploadList: [],
      fileType: ["doc", "xls", "ppt", "txt", "pdf", "docx", "zip", "jpg", "png"], // 上传附件要求的类型限制
      gnwgkAndFzqs: '',
      ktGs: '公司科研项目', //打开选择课题归属弹窗后的默认课题归属
      ktgsVisible: false, //选择课题归属弹窗
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedLxglXmsbFj: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目申报表格数据
      xmsbList: [],
      // 附件表格数据
      lxglXmsbFjList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ktGs: null,
        year: null,
        ktName: null,
        processStatus: null,
        deptId: null,
        userId: this.$store.state.user.id,
      },
      // 表单参数
      form: {},
      // 列信息
      columns: [
        { key: 0, label: `年度`, visible: true }, { key: 1, label: `课题编号`, visible: true }, { key: 2, label: `课题名称`, visible: true },
        { key: 3, label: `课题归属`, visible: true }, { key: 4, label: `申报单位`, visible: true }, { key: 5, label: `姓名`, visible: true },
        { key: 6, label: `项目总额(万)`, visible: true }, { key: 7, label: `申请资助(万)`, visible: true }, { key: 8, label: `止时间`, visible: true },
        { key: 9, label: `申报日期`, visible: true }, { key: 10, label: `录入人员`, visible: true }
      ],
      // 表单校验
      rules: {
        ktGs: [{required: true, message: "课题归属不能为空", trigger: "change"}],
        year: [{required: true, message: "年度不能为空", trigger: "change"}],
        ktName: [{required: true, message: "课题名称不能为空", trigger: "blur"}],
        ktBh: [{required: true, message: "课题编号不能为空", trigger: "blur"}],
        zrBm: [{required: true, message: "责任部门不能为空", trigger: "change"}],
        ktFl: [{required: true, message: "课题分类不能为空", trigger: "change"}],
        qTime: [{required: true, message: "起时间不能为空", trigger: "blur"}],
        zTime: [{required: true, message: "止时间不能为空", trigger: "blur"}],
        ytGc: [{required: true, message: "依托工程不能为空", trigger: "blur"}],
        sbRq: [{required: true, message: "申报日期不能为空", trigger: "blur"}],
        lrRy: [{required: true, message: "录入人员不能为空", trigger: "blur"}],
        xmFlCwxt: [{required: true, message: "项目分类(财务系统)不能为空", trigger: "change"}],
        ssLy: [{required: true, message: "所属领域不能为空", trigger: "change"}],
        gqFw: [{required: true, message: "高企服务不能为空", trigger: "change"}],
        xmYfJb: [{required: true, message: "项目研发级别不能为空", trigger: "change"}],
        hzFs: [{required: true, message: "合作方式不能为空", trigger: "change"}],
        gj: [{required: true, message: "国家不能为空", trigger: "change"}],
        bz: [{required: true, message: "币种不能为空", trigger: "change"}],
        ssLyCwxt: [{required: true, message: "所属领域(财务系统)不能为空", trigger: "change"}],
        // fzName: [{required: true, message: "姓名不能为空", trigger: "blur"}],
        fzXb: [{required: true, message: "性别不能为空", trigger: "change"}],
        fzNl: [{required: true, message: "年龄不能为空", trigger: "blur"}],
        fzZy: [{required: true, message: "专业不能为空", trigger: "blur"}],
        fzPhone: [{required: true, message: "联系电话不能为空", trigger: "blur"}],
        fzZc: [{required: true, message: "职称不能为空", trigger: "change"}],
        fzYzbm: [{required: true, message: "邮政编码不能为空", trigger: "blur"}],
        txdz: [{required: true, message: "通讯地址不能为空", trigger: "blur"}],
        zrs: [{required: true, message: "总人数不能为空", trigger: "blur"}],
        gjrs: [{required: true, message: "高级人数不能为空", trigger: "blur"}],
        zjrs: [{required: true, message: "中级人数不能为空", trigger: "blur"}],
        yjsrs: [{required: true, message: "研究生人数不能为空", trigger: "blur"}],
        cjrs: [{required: true, message: "初级人数不能为空", trigger: "blur"}],
        xmze: [{required: true, message: "项目总额(万)不能为空", trigger: "blur"}],
        sqzz: [{required: true, message: "申请资助(万)不能为空", trigger: "blur"}],
        zcje: [{required: true, message: "自筹金额不能为空", trigger: "blur"}],
      },
    };
  },
  methods: {
    // 计划进度上移方法
    moveJhjdUp(index) {
      if (index > 0) {
        const item = this.lxglXmsbJhjdList.splice(index, 1)[0];
        this.lxglXmsbJhjdList.splice(index - 1, 0, item);
      }
    },
    // 计划进度下移方法
    moveJhjdDown(index) {
      if (index < this.lxglXmsbJhjdList.length - 1) {
        const item = this.lxglXmsbJhjdList.splice(index, 1)[0];
        this.lxglXmsbJhjdList.splice(index + 1, 0, item);
      }
    },
    // 组成人员上移方法
    moveUp(index) {
      if (index > 0) {
        const item = this.lxglXmsbZcryList.splice(index, 1)[0];
        this.lxglXmsbZcryList.splice(index - 1, 0, item);
      }
    },
    // 组成人员下移方法
    moveDown(index) {
      if (index < this.lxglXmsbZcryList.length - 1) {
        const item = this.lxglXmsbZcryList.splice(index, 1)[0];
        this.lxglXmsbZcryList.splice(index + 1, 0, item);
      }
    },
    //发起任务
    handleStartTask() {
      const row = this.selectedRow; // 获取当前选中的行
      if (!row) {
        this.$message.error("请先选择一行数据");
        return;
      }
      this.$confirm("是否确认发起申请？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          startTask({ businessKey: row.xmsbId, businessType: 2 }).then(res => {
            this.getList();
            this.$modal.msgSuccess("发起成功");
            this.selectedRow = null
          });
        })
        .catch(() => {});
    },
    //关闭上传附件弹窗后
    fjClose(){
      this.fileList = []
      this.allFilesUploaded = false
    },
    // 查询子表信息
    handleButtonClick(row) {
      this.$refs.xmxq.handleOpen(row);
    },
    // 查询项目总额信息(打开项目总额弹窗)
    xmZeButtonClick(row) {
      this.$refs.xmze.handleOpen(row);
    },
    //研发设备Excel粘贴模板下载按钮
    handleDownloadYfsbExcel() {
      let a = document.createElement('a');
      a.href = `/static/设备（专门用于研发主要仪器、设备清单）粘贴模板.xlsx`;
      a.download = '设备（专门用于研发主要仪器、设备清单）粘贴模板.xlsx';
      a.click();
    },
    // 设备（专门用于研发主要仪器、设备清单） 粘贴
    handleYfsbPasteFromExcel() {
      const pasteHandler = (e) => {
        e.preventDefault();
        const clipboardData = e.clipboardData || window.clipboardData;
        const pastedData = clipboardData.getData('text/plain').trim();
        if (pastedData) {
          const rows = pastedData.split('\n');
          const parsedData = rows.map(row => row.split('\t').map(cell => cell.replace(/\r$/, '')));
          parsedData.forEach(row => {
            if (row.length >= 1) {
              // 调用handleAddLxglXmsbYfsb并传递解析后的数据
              this.handleAddLxglXmsbYfsb({
                sbName: row[0],
                sbModel: row[1],
                sbPrice: row[2],
                sbRemarks: row[3]
              });
            }
          });
          console.log("解析并添加后的数据：", this.lxglXmsbYfsbList);
        }
        document.removeEventListener('paste', pasteHandler);
      };
      document.addEventListener('paste', pasteHandler, {once: true});
    },
    // 设备（专门用于研发主要仪器、设备清单）添加按钮操作
    handleAddsLxglXmsbYfsb() {
      let obj = {};
      obj.sbName = "";
      obj.sbModel = "";
      obj.sbPrice = "";
      obj.sbRemarks = "";
      this.lxglXmsbYfsbList.push(obj);
    },
    // 设备（专门用于研发主要仪器、设备清单）添加按钮操作(粘贴用)
    handleAddLxglXmsbYfsb(data) {
      // 修改此方法以接受一个数据参数
      if (data) {
        // 直接使用传入的数据
        this.lxglXmsbYfsbList.push(data);
      } else {
        // 如果没有传入数据，则添加一个空对象
        let obj = {
          sbName: "",
          sbModel: "",
          sbPrice: "",
          sbRemarks: ""
        };
        this.lxglXmsbYfsbList.push(obj);
      }
    },
    //对研发费用预算表下表进行汇总
    getSummariesFfyys(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '';
        } else {
          if (column.property === 'xm') {
            // 对于'xm'列，直接设置为"文字"
            sums[index] = '汇总（1+5+10+15+20+24+29+30+36）';
          } else if (['xmZys', 'oneYs', 'towYs', 'threeYs', 'fourYs', 'fiveYs'].includes(column.property)) {
            // 对于需要汇总的列（xmZys, oneYs, towYs, threeYs, fourYs, fiveYs）
            const targetRows = [1, 5, 10, 15, 20, 24, 29, 30, 36];
            let values = data
              .filter((_, rowIndex) => targetRows.includes(rowIndex + 1))
              .map(item => Number(item[column.property]));

            sums[index] = !values.every(value => isNaN(value))
              ? values.reduce((prev, curr) => prev + (isNaN(Number(curr)) ? 0 : Number(curr)), 0)
              + (column.property === 'xmZys' ? '' : '')
              : '';
            this.form.xmze = sums[2];
          } else {
            // 对于其他不需要特殊处理的列，可以留空、设置默认值或进行其他处理
            sums[index] = '';
          }
        }
      });
      return sums;
    },
    /**
     * 计算  -- 预算
     * @param index
     * @param ysNum
     */
    calcCloumVal(index, ysNum) {
      let that = this;
      if (ysNum === undefined) {
        return
      }
      if (that.lxglXmsbYffyysList[index].xmZys === undefined) {
        this.$set(that.lxglXmsbYffyysList[index], 'xmZys', ysNum);
      } else {
        var total = Number(that.lxglXmsbYffyysList[index].xmZys) + Number(ysNum);
        this.$set(that.lxglXmsbYffyysList[index], 'xmZys', total);
      }

      that.calcTotal(index);
    },
    jianCloumVal(index, ysNum) {
      let that = this;
      // 第一次输入
      if (ysNum === undefined) {
        return
      }
      //已经有值 则减去
      that.lxglXmsbYffyysList[index].xmZys = that.lxglXmsbYffyysList[index].xmZys - Number(ysNum);
    },
    //计算列总值
    calcTotal(index) {
      let that = this;
      //前三行
      if (index < 4) {
        //总预算
        //计算行索引 1,2,3  起始索引 1  结束索引为 3  字段名 xmZys
        let oneRowVal = that.publicCalc(1, 3, "xmZys");
        this.$set(that.lxglXmsbYffyysList[0], 'xmZys', oneRowVal);
        // 第一年度
        //计算行索引 1,2,3  起始索引 1  结束索引为 3  字段名 oneYs
        let oneRowValOne = that.publicCalc(1, 3, "oneYs");
        this.$set(that.lxglXmsbYffyysList[0], 'oneYs', oneRowValOne);
        // 第二年度
        let oneRowValTwo = that.publicCalc(1, 3, "towYs");
        this.$set(that.lxglXmsbYffyysList[0], 'towYs', oneRowValTwo);
        // 第三年度
        let oneRowValThree = that.publicCalc(1, 3, "threeYs");
        this.$set(that.lxglXmsbYffyysList[0], 'threeYs', oneRowValThree);
        // 第四年度
        let oneRowValFour = that.publicCalc(1, 3, "fourYs");
        this.$set(that.lxglXmsbYffyysList[0], 'fourYs', oneRowValFour);
        // 第五年度
        let oneRowValFive = that.publicCalc(1, 3, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[0], 'fiveYs', oneRowValFive);
      }
      // 第五行  >4  然后复制上边
      if (index > 4 && index < 9) {
        //总预算
        let towRowVal = that.publicCalc(5, 8, "xmZys");
        this.$set(that.lxglXmsbYffyysList[4], 'xmZys', towRowVal);
        //  第一年度
        let towRowValOne = that.publicCalc(5, 8, "oneYs");
        this.$set(that.lxglXmsbYffyysList[4], 'oneYs', towRowValOne);
        //  第二年度
        let towRowValTwo = that.publicCalc(5, 8, "towYs");
        this.$set(that.lxglXmsbYffyysList[4], 'towYs', towRowValTwo);
        //  第三年度
        let towRowValThree = that.publicCalc(5, 8, "threeYs");
        this.$set(that.lxglXmsbYffyysList[4], 'threeYs', towRowValThree);
        //  第四年度
        let towRowValFour = that.publicCalc(5, 8, "fourYs");
        this.$set(that.lxglXmsbYffyysList[4], 'fourYs', towRowValFour);
        //  第五年度
        let towRowValFive = that.publicCalc(5, 8, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[4], 'fiveYs', towRowValFive);
      }
      //  第十行  >9     然后复制上边
      if (index > 9 && index < 15) {
        //总预算
        let threeRowVal = that.publicCalc(10, 14, "xmZys");
        this.$set(that.lxglXmsbYffyysList[9], 'xmZys', threeRowVal);
        //  第一年度
        let threeRowValOne = that.publicCalc(10, 14, "oneYs");
        this.$set(that.lxglXmsbYffyysList[9], 'oneYs', threeRowValOne);
        //  第二年度
        let threeRowValTwo = that.publicCalc(10, 14, "towYs");
        this.$set(that.lxglXmsbYffyysList[9], 'towYs', threeRowValTwo);
        //  第三年度
        let threeRowValThree = that.publicCalc(10, 14, "threeYs");
        this.$set(that.lxglXmsbYffyysList[9], 'threeYs', threeRowValThree);
        //  第四年度
        let threeRowValFour = that.publicCalc(10, 14, "fourYs");
        this.$set(that.lxglXmsbYffyysList[9], 'fourYs', threeRowValFour);
        //  第五年度
        let threeRowValFive = that.publicCalc(10, 14, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[9], 'fiveYs', threeRowValFive);
      }
      //  第15行  >14     然后复制上边
      if (index > 14 && index < 20) {
        //总预算
        let fourRowVal = that.publicCalc(15, 19, "xmZys");
        this.$set(that.lxglXmsbYffyysList[14], 'xmZys', fourRowVal);
        //  第一年度
        let fourRowValOne = that.publicCalc(15, 19, "oneYs");
        this.$set(that.lxglXmsbYffyysList[14], 'oneYs', fourRowValOne);
        //  第二年度
        let fourRowValTwo = that.publicCalc(15, 19, "towYs");
        this.$set(that.lxglXmsbYffyysList[14], 'towYs', fourRowValTwo);
        //  第三年度
        let fourRowValThree = that.publicCalc(15, 19, "threeYs");
        this.$set(that.lxglXmsbYffyysList[14], 'threeYs', fourRowValThree);
        //  第四年度
        let fourRowValFour = that.publicCalc(15, 19, "fourYs");
        this.$set(that.lxglXmsbYffyysList[14], 'fourYs', fourRowValFour);
        //  第五年度
        let fourRowValFive = that.publicCalc(15, 19, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[14], 'fiveYs', fourRowValFive);
      }
      //  第20行  >19     然后复制上边
      if (index > 19 && index < 24) {
        //总预算
        let fourRowVal = that.publicCalc(20, 23, "xmZys");
        this.$set(that.lxglXmsbYffyysList[19], 'xmZys', fourRowVal);
        //  第一年度
        let fourRowValOne = that.publicCalc(20, 23, "oneYs");
        this.$set(that.lxglXmsbYffyysList[19], 'oneYs', fourRowValOne);
        //  第二年度
        let fourRowValTwo = that.publicCalc(20, 23, "towYs");
        this.$set(that.lxglXmsbYffyysList[19], 'towYs', fourRowValTwo);
        //  第三年度
        let fourRowValThree = that.publicCalc(20, 23, "threeYs");
        this.$set(that.lxglXmsbYffyysList[19], 'threeYs', fourRowValThree);
        //  第四年度
        let fourRowValFour = that.publicCalc(20, 23, "fourYs");
        this.$set(that.lxglXmsbYffyysList[19], 'fourYs', fourRowValFour);
        //  第五年度
        let fourRowValFive = that.publicCalc(20, 23, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[19], 'fiveYs', fourRowValFive);
      }
      //  第24行  >23     然后复制上边
      if (index > 23 && index < 29) {
        //总预算
        let fiveRowVal = that.publicCalc(24, 28, "xmZys");
        this.$set(that.lxglXmsbYffyysList[23], 'xmZys', fiveRowVal);
        //  第一年度
        let fiveRowValOne = that.publicCalc(24, 28, "oneYs");
        this.$set(that.lxglXmsbYffyysList[23], 'oneYs', fiveRowValOne);
        //  第二年度
        let fiveRowValTwo = that.publicCalc(24, 28, "towYs");
        this.$set(that.lxglXmsbYffyysList[23], 'towYs', fiveRowValTwo);
        //  第三年度
        let fiveRowValThree = that.publicCalc(24, 28, "threeYs");
        this.$set(that.lxglXmsbYffyysList[23], 'threeYs', fiveRowValThree);
        //  第四年度
        let fiveRowValFour = that.publicCalc(24, 28, "fourYs");
        this.$set(that.lxglXmsbYffyysList[23], 'fourYs', fiveRowValFour);
        //  第五年度
        let fiveRowValFive = that.publicCalc(24, 28, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[23], 'fiveYs', fiveRowValFive);
      }
      //  第30行  >29     然后复制上边
      if (index > 29 && index < 36) {
        //总预算
        let fiveRowVal = that.publicCalc(30, 35, "xmZys");
        this.$set(that.lxglXmsbYffyysList[29], 'xmZys', fiveRowVal);
        //  第一年度
        let fiveRowValOne = that.publicCalc(30, 35, "oneYs");
        this.$set(that.lxglXmsbYffyysList[29], 'oneYs', fiveRowValOne);
        //  第二年度
        let fiveRowValTwo = that.publicCalc(30, 35, "towYs");
        this.$set(that.lxglXmsbYffyysList[29], 'towYs', fiveRowValTwo);
        //  第三年度
        let fiveRowValThree = that.publicCalc(30, 35, "threeYs");
        this.$set(that.lxglXmsbYffyysList[29], 'threeYs', fiveRowValThree);
        //  第四年度
        let fiveRowValFour = that.publicCalc(30, 35, "fourYs");
        this.$set(that.lxglXmsbYffyysList[29], 'fourYs', fiveRowValFour);
        //  第五年度
        let fiveRowValFive = that.publicCalc(30, 35, "fiveYs");
        this.$set(that.lxglXmsbYffyysList[29], 'fiveYs', fiveRowValFive);
      }

    },
    //计算
    /**
     * @param startIndex 开始索引
     * @param endIndex  结束索引
     * @param cloumName  列字段名称
     */
    publicCalc(startIndex, endIndex, cloumName) {
      let that = this;
      var oneRowVal = 0;
      for (let i = startIndex; i <= endIndex; i++) {
        oneRowVal += that.publicDefaultNum(that.lxglXmsbYffyysList[i][cloumName]);
      }
      return oneRowVal;
    },
    // 赋默认值
    publicDefaultNum(num) {
      if (num === undefined) {
        return 0;
      }
      return Number(num);
    },
    clickJfysRow(row) {
      this.selectedRow = row; // 更新选中的行
      const table = this.$refs.lxglXmsbYffy;
      const selectedRows = table.selection;
      // 否则取消之前选中的行，并选中当前点击的行
      selectedRows.forEach(selectedRow => {
        table.toggleRowSelection(selectedRow);
      });
      table.toggleRowSelection(row);
    },
    //对申请资助列和自筹金额列进行汇总
    getSummaries(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '汇总';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        // 对sqzz 和 zcje 这两列进行总计核算。
        if (column.property === 'sqzz' || column.property === 'zcje') {
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
            sums[index] += '万元';
          } else {
            sums[index] = '---'
          }
        }
      });
      return sums;
    },
    //填报说明弹窗
    openTbsm() {
      this.tbsmVisible = true;
    },
    // 查询部门下拉树结构
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 文件下载处理
    handleDownload(row) {
      const resource = row.fileName;
      // 默认方法
      this.$download.resource(resource);
    },
    yjKfAndPptFjShangChuan() {
      this.fjShangChuan = true;
      this.xmsbFileType = '研究开发计划书及ppt'
    },
    kyFjShangChuan() { //可研性报告上传弹窗
      this.fjShangChuan = true;
      this.xmsbFileType = '可行性研究报告'
    },
    cxbgFjShangChuan() { //查新报告上传弹窗
      this.fjShangChuan = true;
      this.xmsbFileType = '查新报告'
    },
    zscqfxFjShangChuan() { //知识产权分析报告上传弹窗
      this.fjShangChuan = true;
      this.xmsbFileType = '知识产权分析报告'
    },
    xmspyjFjShangChuan() { //项目审批意见上传弹窗
      this.fjShangChuan = true;
      this.xmsbFileType = '项目审批意见'
    },
    // 去除文件名路径前缀
    getFileNames(row) {
      // 从路径中提取文件名
      return row.fileName.split('/').pop(); // 返回文件名部分
    },
    // 选择项目负责人相关信息(从人才平台列表获取信息)
    selectUser() {
      this.$refs.kjrydx.handleOpen();
    },
    // 查询项目申报列表
    getList() {
      this.loading = true;
      getXmsbList(this.queryParams).then(response => {
        this.xmsbList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 关闭按钮
    cancel() {
      this.open = false;
      this.modifyProject = false;
      this.reset();
      this.activeName = 'xmjbxx'
    },
    // 表单重置
    reset() {
      this.form = {
        ktBhnumber: '', ktBhBm: '', xmsbId: null, ktGs: this.ktGs, year: new Date().getFullYear(),
        ktName: null, ktBh: new Date().getFullYear() + '-' + this.ktBhBm + '-' + this.ktBhnumber,
        zrBm: null, ktFl: null, qTime: null, zTime: null, ytGc: null, sbRq: null, lrRy: this.$store.state.user.name,
        xmFlCwxt: null, ssLy: null, gqFw: null, xmYfJb: null, hzFs: null, gj: 'CHN', bz: 'CNY', ssLyCwxt: null,
        fzName: null, fzXb: null, fzNl: null, fzZy: null, fzPhone: null, fzZc: null, fzYzbm: null, txdz: null,
        zrs: 0, gjrs: 0, zjrs: 0, yjsrs: 0, cjrs: 0, xmze: 0, sqzz: 0, zcje: 0, sqDwYj: null, csYj: null, mdAndYy: null,
        gnwgkAndFzqs: null, zyjjKfnr: null, gjJs: null, cxx: null, yqddJsjjzb: null, yqcgAndTgdxs: null, ktfzrQkjs: null,
        createBy: null, createTime: null, updateBy: null, updateTime: null, userId: null, deptId: null
      };
      this.lxglXmsbFjList = [];
      this.lxglXmsbJhjdList = [];
      this.lxglXmsbYffyList = [];
      this.lxglXmsbYffyysList = [];
      this.lxglXmsbYfclList = [];
      this.lxglXmsbYfsbList = [];
      this.lxglXmsbZjsyfList = [];
      this.lxglXmsbZcryList = [];
      this.resetForm("formDialog");
    },
    // 修改按钮操作
    handleUpdate(row) {
      this.loadings = true
      // this.activeName = 'xmjbxx'
      this.reset();
      const xmsbId = row.businessKey
      this.xmsbIdEdit = row.businessKey;
      getXmsb(xmsbId).then(response => {
        this.form = response.data;
        if (this.form.ktFl) {
          this.form.ktFl = this.form.ktFl.split(",");
        }
        // 将qTime和zTime转回为monthrange所需的数组格式
        let qTimeStr = response.data.qTime;
        let zTimeStr = response.data.zTime;
        // 将字符串解析为年份和月份
        let qTimeParts = qTimeStr.split('-');
        let zTimeParts = zTimeStr.split('-');
        // 创建日期对象数组
        let qTime = new Date(parseInt(qTimeParts[0]), parseInt(qTimeParts[1]) - 1);
        let zTime = new Date(parseInt(zTimeParts[0]), parseInt(zTimeParts[1]), 0);
        // 创建 monthrange 格式的数组
        this.form.qTime = [qTime, zTime]
        this.lxglXmsbFjList = response.data.lxglXmsbFjList;
        selectLlglXmsbByjhjdByXmsbId(xmsbId).then(res => {
          this.lxglXmsbJhjdList = res.data.lxglXmsbJhjdList;
        });
        selectLlglXmsbByyffyByXmsbId(xmsbId).then(res => {
          this.lxglXmsbYffyList = res.data.lxglXmsbYffyList;
        });
        selectLlglXmsbByyffysByXmsbId(xmsbId).then(res => {
          this.lxglXmsbYffyysList = res.data.lxglXmsbYffyysList;
          //如果研发费用预算下表没有数据
          if (this.lxglXmsbYffyysList.length === 0) {
            //添加基础信息
            this.handleAddLxglXmsbYffyys();
          }
        });
        selectLlglXmsbByYfclByXmsbId(xmsbId).then(res => {
          this.lxglXmsbYfclList = res.data.lxglXmsbYfclList;
        })
        selectLlglXmsbYfsbByXmsbId(xmsbId).then(res => {
          this.lxglXmsbYfsbList = res.data.lxglXmsbYfsbList;
        })
        selectLlglXmsbZjsyfByXmsbId(xmsbId).then(res => {
          this.lxglXmsbZjsyfList = res.data.lxglXmsbZjsyfList;
        })
        selectLlglXmsbZcryByXmsbId(xmsbId).then(res => {
          this.lxglXmsbZcryList  = res.data.lxglXmsbZcryList ;
        })
        this.modifyProject = true; //打开修改弹窗按钮
        this.title = "修改项目申报";
        setTimeout(() => {
          this.loadings = false
        }, 500)
      });
    },
    // 提交按钮
    submitForm() {
      // 将日期数组转换为字符串格式
      let qTimeStart = this.form.qTime[0].getFullYear() + '-' + (this.form.qTime[0].getMonth() + 1).toString().padStart(2, '0');
      let qTimeEnd = this.form.qTime[1].getFullYear() + '-' + (this.form.qTime[1].getMonth() + 1).toString().padStart(2, '0');
      this.form.qTime = qTimeStart
      this.form.zTime = qTimeEnd

      this.$refs["formDialog"].validate(valid => {
        if (valid) {
          this.form.lxglXmsbFjList = this.lxglXmsbFjList;
          this.form.lxglXmsbJhjdList = this.lxglXmsbJhjdList;
          this.form.lxglXmsbYffyList = this.lxglXmsbYffyList;
          this.form.lxglXmsbYffyysList = this.lxglXmsbYffyysList;
          this.form.lxglXmsbYfclList = this.lxglXmsbYfclList;
          this.form.lxglXmsbYfsbList = this.lxglXmsbYfsbList;
          this.form.lxglXmsbZjsyfList = this.lxglXmsbZjsyfList;
          this.form.lxglXmsbZcryList = this.lxglXmsbZcryList;
          if(this.form.ktFl){
            //课题分类  数组 转 字符串
            this.form.ktFl = this.form.ktFl.join(",");
          }
          if (this.form.xmsbId != null) {
            updateXmsb(this.form).then(response => {
              this.$alert('保存成功!', '提醒', {
                type: 'success',
                confirmButtonText: '确定',
              });
              this.modifyProject = false
            });
          }
        }
      });
    },
    // 项目计划进度和目标序号
    rowLxglXmsbJhjdIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 项目计划进度和目标添加按钮操作
    handleAddLxglXmsbJhjd() {
      let obj = {};
      obj.ksRq = "";
      obj.jsRq = "";
      obj.yfNr = "";
      obj.jdMb = "";
      this.lxglXmsbJhjdList.push(obj);
    },
    // 项目计划进度和目标删除按钮操作
    handleDeleteLxglXmsbJhjd() {
      if (this.checkedLxglXmsbJhjd.length === 0) {
        this.$modal.msgError("请先选择要删除的项目计划进度和目标数据");
      } else {
        const lxglXmsbJhjdList = this.lxglXmsbJhjdList;
        const checkedLxglXmsbJhjd = this.checkedLxglXmsbJhjd;
        this.lxglXmsbJhjdList = lxglXmsbJhjdList.filter(function (item) {
          return checkedLxglXmsbJhjd.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbJhjdSelectionChange(selection) {
      this.checkedLxglXmsbJhjd = selection.map(item => item.index)
    },
    // 研发费用预算上序号
    rowLxglXmsbYffyIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 研发费用预算上添加按钮操作
    handleAddLxglXmsbYffy() {
      let obj = {};
      obj.yffyYear = "";
      obj.sqzz = "";
      obj.zcje = "";
      obj.remark = "";
      this.lxglXmsbYffyList.push(obj);
    },
    // 研发费用预算上删除按钮操作
    handleDeleteLxglXmsbYffy() {
      if (this.checkedLxglXmsbYffy.length === 0) {
        this.$modal.msgError("请先选择要删除的研发费用预算上数据");
      } else {
        const lxglXmsbYffyList = this.lxglXmsbYffyList;
        const checkedLxglXmsbYffy = this.checkedLxglXmsbYffy;
        this.lxglXmsbYffyList = lxglXmsbYffyList.filter(function (item) {
          return checkedLxglXmsbYffy.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbYffySelectionChange(selection) {
      this.checkedLxglXmsbYffy = selection.map(item => item.index)
    },
    // 附件序号
    rowLxglXmsbFjIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    //上传文件之前的钩子
    handleBeforeUpload(file) {
      let that = this;
      // 校检文件类型
      if (this.fileType) {
        const fileName = file.name.split('.');
        const fileExt = fileName[fileName.length - 1];
        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
        if (!isTypeOk) {
          this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
          return false;
        }
        // 校检文件大小
        if (this.fileSize) {
          const isLt = file.size / 1024 / 1024 < this.fileSize;
          if (!isLt) {
            this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
            return false;
          }
        }
        this.$modal.loading("正在上传文件，请稍候...");
        this.number++;
        return true;
      }
    },
    // 对象转成指定字符串分隔
    listToString(list, separator) {
      let strs = "";
      separator = separator || ",";
      for (let i in list) {
        strs += list[i].url + separator;
      }
      return strs !== '' ? strs.substr(0, strs.length - 1) : '';
    },
    // 上传失败
    handleUploadError() {
      this.$modal.msgError("上传文件失败，请重试");
      this.$modal.closeLoading();
    },
    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传成功
    handleUploadSuccess(res, file) {
      let that = this;
      if (res.code === 200) {
        this.uploadList.push({name: res.fileName, url: res.fileName, size: that.formatFileSize(file.size)});
        let itemFile = {
          "xmsbId": that.xmsbIdEdit,
          "fileType": that.xmsbFileType,
          "fileName": res.fileName,
          "fileSize": that.formatFileSize(file.size)
        };
        // 添加数据
        insertLxglXmsbFjByxmsbId(itemFile).then(resFil => {
          that.getXmsbFjList();
        })
        this.uploadedSuccessfully();
      } else {
        this.number--;
        this.$modal.closeLoading();
        this.$modal.msgError(res.msg);
        this.$refs.fileUpload.handleRemove(file);
        this.uploadedSuccessfully();
      }
      this.allFilesUploaded = true
      this.$modal.msgSuccess("上传成功")
      // this.fjShangChuan = false
    },
    // 查询附件列表
    getXmsbFjList() {
      let that = this;
      //根据主表主键ID查询附件
      selectLxglXmsbFjList(that.xmsbIdEdit).then(resFileList => {
        that.lxglXmsbFjList = resFileList.data;
      })
    },
    // 删除附件
    handleXmsbFileDelete(row) {
      let that = this;
      // 根据附件表ID删除附件
      removeFileBySunId(row.fjId).then(res => {
        that.$message.success("移除附件成功！")
        that.getXmsbFjList();
      })
    },
    // 显示文件大小为KB, MB, GB, TB
    formatFileSize(size) {
      if (size === 0) return '0 Bytes';
      const k = 1024;
      const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
      const i = Math.floor(Math.log(size) / Math.log(k));
      return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
    },
    // 上传结束处理
    uploadedSuccessfully() {
      if (this.number > 0 && this.uploadList.length === this.number) {
        this.fileList = this.fileList.concat(this.uploadList);
        this.fileList = this.fileList.map(item => {
          // 使用replace方法去除name中的特定前缀
          item.name = item.name.split('/').pop();
          return item;
        });
        this.uploadList = [];
        this.number = 0;
        this.$emit("input", this.listToString(this.fileList));
        this.$modal.closeLoading();
      }
    },
    // 附件删除按钮操作
    handleDeleteLxglXmsbFj() {
      if (this.checkedLxglXmsbFj.length === 0) {
        this.$modal.msgError("请先选择要删除的附件数据");
      } else {
        const lxglXmsbFjList = this.lxglXmsbFjList;
        const checkedLxglXmsbFj = this.checkedLxglXmsbFj;
        this.lxglXmsbFjList = lxglXmsbFjList.filter(function (item) {
          return checkedLxglXmsbFj.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbFjSelectionChange(selection) {
      this.checkedLxglXmsbFj = selection.map(item => item.index)
    },
    // 研发费用预算下序号
    rowLxglXmsbYffyysIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 研发费用预算下添加按钮操作
    handleAddLxglXmsbYffyys() {
      const items = [
        "一、研发活动直接消耗的材料、燃料和动力费用", "1.材料", "2.燃料", "3.动力费用",
        "二、直接从事研发活动的本企业在职人员费用", "1.工资、薪金", "2.津贴、补贴", "3.奖金", "4.五险一金或五险二金",
        "三、专门用于研发活动的有关折旧费及长期待摊费用", "1.在用建筑物折旧费", "2.仪器折旧费", "3.设备折旧费", "4.长期待摊费用",
        "四、专门用于研发活动的有关租赁费、运行维护费", "1.仪器租赁费", "2.设备租赁费", "3.仪器运行维护费", "4.设备运行维护费",
        "五、专门用于研发活动的有关无形资产摊销费", "1.软件", "2.专利权", "3.非专利技术",
        "六、专门用于中间试验和产品试制的模具、工艺装备开发及制造费，设备调整及检验费，样品、样机及一般测试手段购置费，试制产品的检验费", "1.模具、工艺装备开发及制造费", "2.设备调整及检验费", "3.样品、样机及一般测试手段购置费", "4.试制产品的检验费",
        "七、研发成果论证、鉴定、评审、验收费用",
        "八、与研发活动直接相关的其它费用", "1.新产品设计费", "2.新工艺规程制定费", "3.技术图书资料费", "4.资料翻译费", "5.其他（办公费、通讯费、专利申请维护费、高新科技研发保险费等）",
        "九、委外费用",
      ];

      items.forEach(item => {
        let obj = {
          xm: item,
          xmZys: "",
          oneYs: "",
          towYs: "",
          threeYs: "",
          fourYs: "",
          fiveYs: ""
        };
        this.lxglXmsbYffyysList.push(obj);
      });
    },
    // 复选框选中数据
    handleLxglXmsbYffyysSelectionChange(selection) {
      this.checkedLxglXmsbYffyys = selection.map(item => item.index)
    },
    // 直接用于研发的主要材料序号 */
    rowLxglXmsbYfclIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 直接用于研发的主要材料 添加按钮操作
    handleAddsLxglXmsbYfcl() {
      let obj = {};
      obj.clName = "";
      obj.clUnit = "";
      obj.clDosage = "";
      obj.clRemarks = "";
      this.lxglXmsbYfclList.push(obj);
    },
    // 直接用于研发的主要材料 添加按钮操作(粘贴用)
    handleAddLxglXmsbYfcl(data) {
      // 修改此方法以接受一个数据参数
      if (data) {
        // 直接使用传入的数据
        this.lxglXmsbYfclList.push(data);
      } else {
        // 如果没有传入数据，则添加一个空对象
        let obj = {
          clName: "",
          clUnit: "",
          clDosage: "",
          clRemarks: ""
        };
        this.lxglXmsbYfclList.push(obj);
      }
    },
    // 直接用于研发的主要材料 粘贴
    handleYfclPasteFromExcel() {
      const pasteHandler = (e) => {
        e.preventDefault();
        const clipboardData = e.clipboardData || window.clipboardData;
        const pastedData = clipboardData.getData('text/plain').trim();
        if (pastedData) {
          const rows = pastedData.split('\n');
          const parsedData = rows.map(row => row.split('\t').map(cell => cell.replace(/\r$/, '')));
          parsedData.forEach(row => {
            if (row.length >= 1) {
              // 调用handleAddLxglXmsbYfsb并传递解析后的数据
              this.handleAddLxglXmsbYfcl({
                clName: row[0],
                clUnit: row[1],
                clDosage: row[2],
                clRemarks: row[3]
              });
            }
          });
        }
        document.removeEventListener('paste', pasteHandler);
      };
      document.addEventListener('paste', pasteHandler, {once: true});
    },
    // 直接用于研发的主要材料删除按钮操作 */
    handleDeleteLxglXmsbYfcl() {
      if (this.checkedLxglXmsbYfcl.length === 0) {
        this.$modal.msgError("请先选择要删除的直接用于研发的主要材料数据");
      } else {
        const lxglXmsbYfclList = this.lxglXmsbYfclList;
        const checkedLxglXmsbYfcl = this.checkedLxglXmsbYfcl;
        this.lxglXmsbYfclList = lxglXmsbYfclList.filter(function (item) {
          return checkedLxglXmsbYfcl.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbYfclSelectionChange(selection) {
      this.checkedLxglXmsbYfcl = selection.map(item => item.index)
    },
    // 设备（专门用于研发主要仪器、设备清单）序号
    rowLxglXmsbYfsbIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 设备（专门用于研发主要仪器、设备清单）删除按钮操作
    handleDeleteLxglXmsbYfsb() {
      if (this.checkedLxglXmsbYfsb.length === 0) {
        this.$modal.msgError("请先选择要删除的设备（专门用于研发主要仪器、设备清单）数据");
      } else {
        const lxglXmsbYfsbList = this.lxglXmsbYfsbList;
        const checkedLxglXmsbYfsb = this.checkedLxglXmsbYfsb;
        this.lxglXmsbYfsbList = lxglXmsbYfsbList.filter(function (item) {
          return checkedLxglXmsbYfsb.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbYfsbSelectionChange(selection) {
      this.checkedLxglXmsbYfsb = selection.map(item => item.index)
    },
    // 中间试验费序号
    rowLxglXmsbZjsyfIndex({row, rowIndex}) {
      row.index = rowIndex + 1;
    },
    // 中间试验费添加按钮操作
    handleAddsLxglXmsbZjsyf() {
      let obj = {};
      obj.testingItems = "";
      obj.price = "";
      obj.remarks = "";
      this.lxglXmsbZjsyfList.push(obj);
    },
    // 中间试验费添加按钮操作(用于粘贴)
    handleAddLxglXmsbZjsyf(data) {
      // 修改此方法以接受一个数据参数
      if (data) {
        // 直接使用传入的数据
        this.lxglXmsbZjsyfList.push(data);
      } else {
        // 如果没有传入数据，则添加一个空对象
        let obj = {
          testingItems: "",
          price: "",
          remarks: "",
        };
        this.lxglXmsbZjsyfList.push(obj);
      }
    },
    // 中间试验费 粘贴
    handleZjsyfPasteFromExcel() {
      const customPasteHandler = this.createPasteHandler((row) => {
        // 这里可以根据需要自定义处理每一行数据的逻辑
        this.handleAddLxglXmsbZjsyf({ // 假设这是你原有处理数据的方法
          testingItems: row[0],
          price: row[1],
          remarks: row[2],
        });
      });
      document.addEventListener('paste', customPasteHandler, {once: true});
    },
    // 粘贴通用方法
    createPasteHandler(callback) {
      return function (e) {
        e.preventDefault();
        const clipboardData = e.clipboardData || window.clipboardData;
        const pastedData = clipboardData.getData('text/plain').trim();
        if (pastedData) {
          const rows = pastedData.split('\n');
          const parsedData = rows.map(row => row.split('\t').map(cell => cell.replace(/\r$/, '')));
          parsedData.forEach(row => {
            if (row.length >= 1) {
              // 调用外部传入的回调函数处理每一行数据
              callback(row);
            }
          });
        }
        document.removeEventListener('paste', this);
      };
    },
    // 中间试验费删除按钮操作
    handleDeleteLxglXmsbZjsyf() {
      if (this.checkedLxglXmsbZjsyf.length === 0) {
        this.$modal.msgError("请先选择要删除的中间试验费数据");
      } else {
        const lxglXmsbZjsyfList = this.lxglXmsbZjsyfList;
        const checkedLxglXmsbZjsyf = this.checkedLxglXmsbZjsyf;
        this.lxglXmsbZjsyfList = lxglXmsbZjsyfList.filter(function (item) {
          return checkedLxglXmsbZjsyf.indexOf(item.index) === -1
        });
      }
    },
    // 复选框选中数据
    handleLxglXmsbZjsyfSelectionChange(selection) {
      this.checkedLxglXmsbZjsyf = selection.map(item => item.index)
    },
    /** 研究课题组成人员情况序号 */
    rowLxglXmsbZcryIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 研究课题组成人员情况添加按钮操作 */
    handleAddLxglXmsbZcry() {
      this.$refs.ktryDuoXuan.handleOpen(this.lxglXmsbZcryList);
    },
    /** 研究课题组成人员情况删除按钮操作 */
    handleDeleteLxglXmsbZcry() {
      if (this.checkedLxglXmsbZcry.length == 0) {
        this.$modal.msgError("请先选择要删除的研究课题组成人员情况数据");
      } else {
        const lxglXmsbZcryList = this.lxglXmsbZcryList;
        const checkedLxglXmsbZcry = this.checkedLxglXmsbZcry;
        this.lxglXmsbZcryList = lxglXmsbZcryList.filter(function(item) {
          return checkedLxglXmsbZcry.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleLxglXmsbZcrySelectionChange(selection) {
      this.checkedLxglXmsbZcry = selection.map(item => item.index)
    },
  }
};
</script>

<style scoped>
/* 定义表头中特定类名的文本居中 */
.el-table .custom-header .cell {
  text-align: center !important;
}
/* header 头部背景 */
/deep/ .el-card__header {
  padding: 3px 7px 3px;
  min-height: 10px;
  background-color: aliceblue;
}
.vxe-button--mini.right-align-dropdown .vxe-popup--menu {
  right: 0 !important;
  left: auto !important;
}
</style>
